<?php

namespace App\Remote\TencentLbs;

use Closure;

class Remote extends \App\Remote\Remote
{
    /**
     * @inheritDoc
     */
    static function getBaseUri(): string
    {
        // TODO: Implement getBaseUri() method.
        return "https://apis.map.qq.com";
    }

    /**
     * @inheritDoc
     */
    public static function registerResponseHandle(): Closure
    {
        return function ($data) {
            $response = json_decode($data, true);
            if ($response["status"] !== 0) {
                throw new \Exception(
                    vsprintf("响应数据异常 code: [%s] msg: [%s]", [
                        $response["status"],
                        $response["message"]
                    ])
                );
            }
            return $response["result"];
        }; // TODO: Change the autogenerated stub
    }

    /**
     * @inheritDoc
     */
    public static function buildBasicHeaders(): array
    {
        return parent::buildBasicHeaders(); // TODO: Change the autogenerated stub
    }

    protected static function getConfig(): array
    {
        return [
            "key" => config("tencent.lbs.key")
        ];
    }
}
